<template>
    <a-modal v-model:visible="dialogVisiable" title-align="start" class="chunk-delete-box"  @ok="handleOk" @cancel="handleCancel">
        <template #title>{{tipsText.title}}</template>
        <div class="chunk-delete-info-box" :class="type === 'del' ? 'del-icon' : 'open-icon'">
          <icon-exclamation-circle-fill class="text-red-600" />
          {{tipsText.tips}}
        </div>
        <template #footer>
          <div class="w-full h-full flex justify-end items-center">
            <a-button @click="handleCancel">取消</a-button>
            <a-button type="primary" class="ml-2" @click="handleSure">确认</a-button>
          </div>
        </template>
      </a-modal>
</template>
<script setup lang="ts">
import { ref, watch } from 'vue'
import { org_delete } from '@/api/orgManagement/orgManagement'
import { Message } from '@arco-design/web-vue';

const dialogVisiable = ref(false)
const emit = defineEmits(['onClose']);
const props = defineProps({
    orgId: Number,
    visiable: Boolean,
    type: String,
    orgName: String,
    tipsText: Object
})
watch(
  () => props.visiable,
  (newVal) => {
    console.log(newVal)
    dialogVisiable.value = newVal;
  }
);

/**
 * 确认
 */
const handleSure = async() => {
  if (props.type === 'del') {
    let res = await org_delete({ code: props.orgId, org_name: props.orgName})
    if (res.code === 200) {
      Message.success('删除成功')
    }
  } else {
    Message.success('账户开通成功')
  }
    emit('onClose', false);
}
/**
 * 取消
 */
const handleCancel = () => {
    emit('onClose', false);
}
</script>
<style lang="less">
.chunk-delete-box{
  .arco-modal-wrapper{
    .arco-modal{
      .arco-modal-header{
        border-bottom: 0!important;
      }
      .arco-modal-footer{
        border-top: 0!important;
      }
    }
  }
}
</style>
<style lang="less" scoped>
.del-icon {
  :deep(.arco-icon) {
    color: #FFAC38;
  }
}
.open-icon {
  :deep(.arco-icon) {
    color: #1459FA;
  }
}
</style>